package com.woniu.mealsService.util;

import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author jiang
 */
public class DateUtils {
    public static String getTime(String dateTime) {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        if (dateTime != null) {
            LocalDateTime localDateTime = LocalDateTime.parse(dateTime, dateTimeFormatter);
            return localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        }
        return null;
    }
    public static LocalDateTime getLocalDateTime(String dateTime) {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        if (dateTime != null) {
            return LocalDateTime.parse(dateTime, dateTimeFormatter);
        }
        return null;
    }
}
